package cn.westv.scps.domain;

import java.io.Serializable;
import java.util.Set;

import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.OneToMany;

import org.codehaus.jackson.annotate.JsonIgnore;
import org.hibernate.annotations.GenericGenerator;

/**
 * Created by Administrator on 2017/08/01.
 */
@Entity(name = "sys_dict")
//@Table(name = "sys_dict")
public class SysDict implements Serializable{
	private String dictId;// 主键
	private String dictName;// 名称
	private String dictCode;// 字典代码
	private String description;// 描述
	 private Set<SysDictItem> sysDictItems;
//	private Set<SysDictItem> sysDictItems = new HashSet<SysDictItem>();

	@Id
	@Column(name = "DICT_ID")
	@GeneratedValue(generator = "uuid")
	@GenericGenerator(name = "uuid", strategy = "uuid")
	public String getDictId() {
		return dictId;
	}

	public void setDictId(String dictId) {
		this.dictId = dictId;
	}

	@Basic
	@Column(name = "DICT_NAME")
	public String getDictName() {
		return dictName;
	}

	public void setDictName(String dictName) {
		this.dictName = dictName;
	}

	@Basic
	@Column(name = "DICT_CODE")
	public String getDictCode() {
		return dictCode;
	}

	public void setDictCode(String dictCode) {
		this.dictCode = dictCode;
	}

	@Basic
	@Column(name = "DESCRIPTION")
	public String getDescription() {
		return description;
	}

	public void setDescription(String description) {
		this.description = description;
	}

	@OneToMany(cascade = CascadeType.ALL, mappedBy = "sysDictEntity")
	@JsonIgnore
	public Set<SysDictItem> getSysDictItems() {
		return sysDictItems;
	}

	@JsonIgnore
	public void setSysDictItems(Set<SysDictItem> sysDictItems) {
		this.sysDictItems = sysDictItems;
	}

	@Override
	public boolean equals(Object o) {
		if (this == o)
			return true;
		if (o == null || getClass() != o.getClass())
			return false;

		SysDict that = (SysDict) o;

		if (dictId != null ? !dictId.equals(that.dictId) : that.dictId != null)
			return false;
		if (dictName != null ? !dictName.equals(that.dictName) : that.dictName != null)
			return false;
		if (dictCode != null ? !dictCode.equals(that.dictCode) : that.dictCode != null)
			return false;
		return description != null ? description.equals(that.description) : that.description == null;
	}

	@Override
	public int hashCode() {
		int result = dictId != null ? dictId.hashCode() : 0;
		result = 31 * result + (dictName != null ? dictName.hashCode() : 0);
		result = 31 * result + (dictCode != null ? dictCode.hashCode() : 0);
		result = 31 * result + (description != null ? description.hashCode() : 0);
		return result;
	}
}
